<template>
	<yd-layout id='productDetail' class=''>
		<img class="header_img" :src="dataObj.title_img" alt="" />
		<div class="content">
			<div class="title c_size_34_48">{{dataObj.title}}</div>
			<div class="c_v_html" v-html="dataObj.content"></div>
			<!--<div class="product_title">产品规格</div>
			<div class="product_label">面膜156g（26克*6片)+精华液30克+精粹水50ml+精华日霜30g+精华洁面乳40g</div>
			<div class="product_title">产品说明</div>
			<div class="product_label">面膜156g（26克*6片)+精华液30克+精粹水50ml+精华日霜30g+精华洁面乳40g</div>-->
		</div>
		<div slot='bottom' class="bottom" v-if="$route.query.uid">
			<div class="bottom_left">
				<img class="bottom_left_img" :src="userObj.avatar" alt="" />
				<div class="bottom_left_msg">
					<div class="bottom_left_msg_name c_text_ellipsis_1">{{userObj.nick_name}}</div>
					<div class="bottom_left_msg_label c_text_ellipsis_1">{{userObj.summary}}</div>
				</div>
			</div> 
			
			<div class="bottom_right">
				<img @click="qrCodeShow=true" class="bottom_right_img_1" src="../../assets/productDetail_1.png" alt="" />
				<a :href="'tel:'+userObj.mobile" style="display: block;">
					<img class="bottom_right_img_2" src="../../assets/productDetail_2.png" alt="" />
				</a>
			</div>
		</div>
		
		<yd-popup v-model="popFlg" position="center" width="90%">
            <div class="qr_pop" >
            	<div class="pop_top">
            		<img class="pop_top_img" :src="userObj.wechat_code" alt="" />
            		<div class="pop_top_label">长按上方二维码扫描添加好友</div>
            	</div>
            	<img @click="qrCodeShow=false" class="pop_close_img" src="../../assets/close_1.png" alt="" />
            </div>
        </yd-popup>
	</yd-layout>
</template>

<script>
	import {Popup} from 'vue-ydui/dist/lib.rem/popup';
	export default{
		components:{
			[Popup.name]:Popup
		},
		data(){
			return {
				popFlg:false,
				dataObj:{},
				qrCodeShow:false,
				userObj:{},
			}
		},
		created() {
//			var html =document.querySelector('html');
//      	html.style.fontSize = '16px';
			
			this.$root.id = this.$route.query.id
			this.$root.uuid = (parseInt((parseInt(new Date()-0))/1000))+''+(this.$root.userInfo.me.id||0)
			this.$root.submitEvent({
				kind:1,
			})
			this.$store.commit({
				type:'setDataEvent',
				data:{
					kind:1,
					uuid:this.$root.uuid,
					position:0,
					oid:this.$route.query.id,
					uid:this.$root.userInfo&&(JSON.stringify(this.$root.userInfo)!='{}')?this.$root.userInfo.me.id:0
				}
			})
		},
		//销毁实例
		beforeDestroy(){
//			var winWidth = window.innerWidth;
//	        var html =document.querySelector('html');
//      	html.style.fontSize = (winWidth / 750) * 100 + 'px';
			
			this.$root.submitEvent({
				kind:1,
				lastFlg:true
			})
		},
		watch: {
			
		},
		computed: {
			
		},
		mounted(){
			this.articleDetail()
			document.title='产品详情'
			
			if(this.$route.query.uid){
				this.$root.ajax({
					name:'my/namecard',
					type:'post',
					params:{
						uid:this.$route.query.uid
					}
				}).then((d)=>{
					this.userObj = Object.assign({},this.userObj,d.data)
				})
			}
			
		},
		methods:{
			articleDetail(){
				this.$root.ajax({
//					name:'article/detail',
					name:'product/detail',
					type:'get',
					params:{
						id:this.$route.query.id
					}
				}).then((d)=>{
					this.dataObj = Object.assign({},this.dataObj,d.data)
					
					//分享
					if(this.$root.isWeiXin()){
						//分享
						let query = '';
						if(this.$root.config.channel){
						 	query = `params=channelDY2FGoldUrlStrDY${this.$route.name}FGkeyNumDY1FGparamsKey1DYidFGparamsVal1DY${d.data.id}`
						}else{
						 	query = `params=oldUrlStrDY${this.$route.name}FGkeyNumDY1FGparamsKey1DYidFGparamsVal1DY${d.data.id}`
						}
						this.$root.wxShare({
							d:this.dataObj,//分享对象，题目等{title:'',title-img:''}
							query: query,//参数
							desc:this.dataObj.remark//分享详情
						})
					}
				})
			},
		}
	}
</script>

<style lang="scss" large>
	@import './productDetail.scss';
</style>